using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using OpenMVCRM.Entities;

namespace OpenMVCRM.DataAccess
{
    public class Repositary : IRepositary
    {

        public IEnumerable<Entities.Client> GetClients()
        {
            throw new NotImplementedException();
        }

        //public IEnumerable<Entities.Address> GetAddresses(int clientId)
        //{
        //   // return context.Addresses.Where(x => x.ClientID == clientId).ToList();
        //}



        public Entities.User GetUserByEmailAddress(string emailAddress)
        {
            throw new NotImplementedException();
        }

        public Entities.OperationStatus InsertAddress(Entities.Address address)
        {
            throw new NotImplementedException();
        }

        public void Dispose()
        {
            throw new NotImplementedException();
        }


        public Client GetClientById(int id)
        {
            return CompanyDA.GetClientFromID(id);
        }


        public Address GetAddress(int id)
        {
            throw new NotImplementedException();
        }

        private void RemovePrimaryFlagFromAddresses(int clientId)
        {
            throw new NotImplementedException();
            // var res = context.Database.SqlQuery<int>("exec uspRemovePrimaryAddress @clientId", new SqlParameter("clientId", clientId));
        }

        public OperationStatus SaveAddress(Address address)
        {
            return AddressDA.SaveAddress(address);
        }


        public OperationStatus DeleteAddress(int addressId)
        {
            throw new NotImplementedException();

        }


        public OperationStatus InsertCountry(Country country)
        {
            throw new NotImplementedException();
        }

        public OperationStatus InsertState(State state)
        {
            throw new NotImplementedException();
        }


        public IEnumerable<Country> GetCountries()
        {
            return CompanyDA.GetCountries();
        }

        public IEnumerable<State> GetStates(int countryId)
        {
            return CompanyDA.GetStates(countryId);
        }


        public OperationStatus SaveClient(Client client)
        {
            return CompanyDA.SaveCompany(client);
        }

        public OperationStatus UpdateClient(Client client)
        {
            throw new NotImplementedException();
        }


        public OperationStatus DeleteClient(int clientId)
        {
            throw new NotImplementedException();
        }


        public OperationStatus InsertUser(User user)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<Client> GetClientsForOrganization(int organizationID)
        {
            return CompanyDA.GetClientsForOrganization(organizationID);
        }




        public OperationStatus SavePhoneNumber(PhoneNumber phoneNumber)
        {
            return PhoneNumberDA.SavePhoneNumber(phoneNumber);
        }

        #region IRepositary Members

        public IEnumerable<Industry> GetAllIndustries()
        {
            return CompanyDA.GetIndustries();
        }

        #endregion


        #region Contact Person
        public ContactPerson GetContactPersonFromID(int id)
        {
            throw new NotImplementedException();
        }

        public OperationStatus InsertContactPerson(ContactPerson contactPerson)
        {
            return ContactPersonDA.SaveContactPerson(contactPerson);
        }

        public OperationStatus UpdateContactPerson(ContactPerson contactPerson)
        {
            return ContactPersonDA.SaveContactPerson(contactPerson);
        }
        #endregion


        public IList<ContactPerson> GetContactPersons(int organizationId)
        {
            return ContactPersonDA.GetContactPersons(organizationId).ToList();
        }
    }
}
